<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">

        <ui:define name="title">
            <h:outputText value="#{bundle.ListCondicaoPagamentoTitle}"></h:outputText>
        </ui:define>

        <ui:define name="menuLateral">

            <h:form id="formLateralMenuCondicaoPagamentoList">
                
            </h:form>

        </ui:define>

        <ui:define name="body">
            <h:form id="formCondicaoPagamentoList">

                <h:panelGroup id="messagePanel" layout="block">
                    <p:growl />
                </h:panelGroup>

                <h:panelGroup>

                    <p:dataTable id="tableCondicaoPagamento" value="#{condicaoPagamentoController.items}" var="item" 
                                 style="border:solid 1px" emptyMessage="#{bundle.ListCondicaoPagamentoEmpty}">

                        <f:facet name="header">#{bundle.ListCondicaoPagamentoTitle}</f:facet>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCondicaoPagamentoTitle_formaPagamento}"/>
                            </f:facet>
                            <h:outputText value="#{item.formaPagamento.sigla}"/>
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Entrada" />
                            </f:facet>
                            <p:selectBooleanButton value="#{item.entrada}" disabled="true"
                                                   onLabel="Sim" offLabel="Não" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCondicaoPagamentoTitle_vezes}"/>
                            </f:facet>
                            <h:outputText value="#{item.vezes}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCondicaoPagamentoTitle_perJuros}"/>
                            </f:facet>
                            <h:outputText value="#{item.perJuros}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCondicaoPagamentoTitle_multa}"/>
                            </f:facet>
                            <h:outputText value="#{item.multa}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCondicaoPagamentoTitle_diasMulta}"/>
                            </f:facet>
                            <h:outputText value="#{item.diasMulta}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCondicaoPagamentoTitle_taxa}"/>
                            </f:facet>
                            <h:outputText value="#{item.taxa}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <p:commandButton actionListener="#{condicaoPagamentoController.prepareCreate}" 
                                                 value="#{bundle.ListCondicaoPagamentoCreateLink}" 
                                                 update=":formCondicaoPagamentoCreate:pgCondicaoPagamentoCreate" 
                                                 oncomplete="dialogCondicaoPagamentoCreate.show()"/>
                            </f:facet>
                            <p:commandButton actionListener="#{condicaoPagamentoController.prepareEdit}" 
                                             value="#{bundle.ListCondicaoPagamentoEditLink}" 
                                             update=":formCondicaoPagamentoEdit:pgCondicaoPagamentoEdit" 
                                             oncomplete="dialogCondicaoPagamentoEdit.show()"/>
                            <p:commandButton actionListener="#{condicaoPagamentoController.destroy}" 
                                             value="#{bundle.ListCondicaoPagamentoDestroyLink}" 
                                             update=":formCondicaoPagamentoList:tableCondicaoPagamento" ajax="false"/>
                        </p:column>
                    </p:dataTable>
                </h:panelGroup>

            </h:form>

            <h:form id="formCondicaoPagamentoCreate">

                <p:dialog header="#{bundle.CreateCondicaoPagamentoTitle}" widgetVar="dialogCondicaoPagamentoCreate" resizable="false" 
                          modal="true" showEffect="slide">
                    <p:panelGrid id="pgCondicaoPagamentoCreate" columns="2">

                        <h:outputLabel value="#{bundle.CreateCondicaoPagamentoLabel_formaPagamento}" 
                                       for="formaPagamento" />
                        <p:selectOneMenu id="formaPagamento" 
                                         value="#{condicaoPagamentoController.selected.formaPagamento}" 
                                         label="#{bundle.CreateCondicaoPagamentoTitle_formaPagamento}" required="true" 
                                         requiredMessage="#{bundle.CreateCondicaoPagamentoRequiredMessage_formaPagamento}">
                            <f:selectItems value="#{formaPagamentoController.itemsAvailableSelectOne}"/>
                        </p:selectOneMenu>
                        
                        <h:outputLabel value="Entrada" for="entrada" />
                        <p:selectBooleanButton id="entrada" value="#{condicaoPagamentoController.selected.entrada}" 
                                               onLabel="Sim" offLabel="Não" />

                        <h:outputLabel value="#{bundle.CreateCondicaoPagamentoLabel_vezes}" for="vezes" />
                        <p:inputText id="vezes" value="#{condicaoPagamentoController.selected.vezes}" 
                                     title="#{bundle.CreateCondicaoPagamentoTitle_vezes}" required="true" 
                                     requiredMessage="#{bundle.CreateCondicaoPagamentoRequiredMessage_vezes}"/>

                        <h:outputLabel value="#{bundle.CreateCondicaoPagamentoLabel_perJuros}" for="perJuros" />
                        <p:inputText id="perJuros" value="#{condicaoPagamentoController.selected.perJuros}" 
                                     title="#{bundle.CreateCondicaoPagamentoTitle_perJuros}" required="true" 
                                     requiredMessage="#{bundle.CreateCondicaoPagamentoRequiredMessage_perJuros}"/>

                        <h:outputLabel value="#{bundle.CreateCondicaoPagamentoLabel_multa}" for="multa" />
                        <p:inputText id="multa" value="#{condicaoPagamentoController.selected.multa}" 
                                     title="#{bundle.CreateCondicaoPagamentoTitle_multa}" required="true" 
                                     requiredMessage="#{bundle.CreateCondicaoPagamentoRequiredMessage_multa}"/>

                        <h:outputLabel value="#{bundle.CreateCondicaoPagamentoLabel_diasMulta}" for="diasMulta" />
                        <p:inputText id="diasMulta" 
                                     value="#{condicaoPagamentoController.selected.diasMulta}" 
                                     title="#{bundle.CreateCondicaoPagamentoTitle_diasMulta}" required="true" 
                                     requiredMessage="#{bundle.CreateCondicaoPagamentoRequiredMessage_diasMulta}"/>
                        
                        <h:outputLabel value="#{bundle.CreateCondicaoPagamentoLabel_taxa}" for="taxa" />
                        <p:inputText id="taxa" value="#{condicaoPagamentoController.selected.taxa}" 
                                     title="#{bundle.CreateCondicaoPagamentoTitle_taxa}" required="true" 
                                     requiredMessage="#{bundle.CreateCondicaoPagamentoRequiredMessage_taxa}"/>
                        
                        <p:commandButton actionListener="#{condicaoPagamentoController.create}" 
                                         update=":formCondicaoPagamentoList:tableCondicaoPagamento" 
                                         value="#{bundle.CreateCondicaoPagamentoSaveLink}" 
                                         oncomplete="#{condicaoPagamentoController.prepareCreate}" ajax="false" />
                        <p:commandButton value="Limpar" type="reset" 
                                         update=":formCondicaoPagamentoCreate:pgCondicaoPagamentoCreate" ajax="false"/>
                    </p:panelGrid>
                    
                </p:dialog>

            </h:form>

            <h:form id="formCondicaoPagamentoEdit">

                <p:dialog header="#{bundle.EditCondicaoPagamentoTitle}" widgetVar="dialogCondicaoPagamentoEdit" resizable="false" 
                          modal="true" showEffect="slide">
                    <p:panelGrid id="pgCondicaoPagamentoEdit" columns="2">

                        <h:outputLabel value="#{bundle.EditCondicaoPagamentoLabel_formaPagamento}" 
                                       for="formaPagamento" />
                        <p:selectOneMenu id="formaPagamento" 
                                         value="#{condicaoPagamentoController.selected.formaPagamento}" 
                                         label="#{bundle.EditCondicaoPagamentoTitle_formaPagamento}" required="true" 
                                         requiredMessage="#{bundle.EditCondicaoPagamentoRequiredMessage_formaPagamento}">
                            <f:selectItems value="#{formaPagamentoController.itemsAvailableSelectOne}"/>
                        </p:selectOneMenu>
                        
                        <h:outputLabel value="Entrada" for="entrada" />
                        <p:selectBooleanButton id="entrada" value="#{condicaoPagamentoController.selected.entrada}" 
                                               onLabel="Sim" offLabel="Não" />

                        <h:outputLabel value="#{bundle.EditCondicaoPagamentoLabel_vezes}" for="vezes" />
                        <p:inputText id="vezes" value="#{condicaoPagamentoController.selected.vezes}" 
                                     title="#{bundle.EditCondicaoPagamentoTitle_vezes}" required="true" 
                                     requiredMessage="#{bundle.EditCondicaoPagamentoRequiredMessage_vezes}"/>

                        <h:outputLabel value="#{bundle.EditCondicaoPagamentoLabel_perJuros}" for="perJuros" />
                        <p:inputText id="perJuros" value="#{condicaoPagamentoController.selected.perJuros}" 
                                     title="#{bundle.EditCondicaoPagamentoTitle_perJuros}" required="true" 
                                     requiredMessage="#{bundle.EditCondicaoPagamentoRequiredMessage_perJuros}"/>

                        <h:outputLabel value="#{bundle.EditCondicaoPagamentoLabel_multa}" for="multa" />
                        <p:inputText id="multa" value="#{condicaoPagamentoController.selected.multa}" 
                                     title="#{bundle.EditCondicaoPagamentoTitle_multa}" required="true" 
                                     requiredMessage="#{bundle.EditCondicaoPagamentoRequiredMessage_multa}"/>

                        <h:outputLabel value="#{bundle.EditCondicaoPagamentoLabel_diasMulta}" for="diasMulta" />
                        <p:inputText id="diasMulta" 
                                     value="#{condicaoPagamentoController.selected.diasMulta}" 
                                     title="#{bundle.EditCondicaoPagamentoTitle_diasMulta}" required="true" 
                                     requiredMessage="#{bundle.EditCondicaoPagamentoRequiredMessage_diasMulta}"/>
                        
                        <h:outputLabel value="#{bundle.EditCondicaoPagamentoLabel_taxa}" for="taxa" />
                        <p:inputText id="taxa" value="#{condicaoPagamentoController.selected.taxa}" 
                                     title="#{bundle.EditCondicaoPagamentoTitle_taxa}" required="true" 
                                     requiredMessage="#{bundle.EditCondicaoPagamentoRequiredMessage_taxa}"/>
                    
                        <p:commandButton actionListener="#{condicaoPagamentoController.update}" 
                                         update=":formCondicaoPagamentoList:tableCondicaoPagamento" 
                                         value="#{bundle.EditCondicaoPagamentoSaveLink}" 
                                         oncomplete="dialogCondicaoPagamentoEdit.hide()" ajax="false" />
                        <p:commandButton value="Cancelar" oncomplete="dialogCondicaoPagamentoEdit.hide()" 
                                         ajax="false"/>
                    </p:panelGrid>
                </p:dialog>

            </h:form>

        </ui:define>
    </ui:composition>

</html>
